package com.rfid.db.bean;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.Generated;

import java.util.Objects;

@Entity
public class Book {

    public static int STATUS_OK = 0;
    public static int STATUS_UNKOWN = 1;

    @org.greenrobot.greendao.annotation.Id(autoincrement = true)
    @Property(nameInDb="id")
    Long Id;

    String name;
    String author;
    String barcode;
    String isbn;
    boolean canBorrow;
    int boxNum;
    String preBorrowReader;//FailBook取代原本意义


    @Generated(hash = 746421312)
    public Book(Long Id, String name, String author, String barcode, String isbn,
            boolean canBorrow, int boxNum, String preBorrowReader) {
        this.Id = Id;
        this.name = name;
        this.author = author;
        this.barcode = barcode;
        this.isbn = isbn;
        this.canBorrow = canBorrow;
        this.boxNum = boxNum;
        this.preBorrowReader = preBorrowReader;
    }
    @Generated(hash = 1839243756)
    public Book() {
    }


    public Long getId() {
        return this.Id;
    }
    public void setId(Long Id) {
        this.Id = Id;
    }
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAuthor() {
        return this.author;
    }
    public void setAuthor(String author) {
        this.author = author;
    }
    public int getBoxNum() {
        return this.boxNum;
    }
    public void setBoxNum(int boxNum) {
        this.boxNum = boxNum;
    }
    public String getBarcode() {
        return this.barcode;
    }
    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public String getPreBorrowReader() {
        return preBorrowReader;
    }

    public void setPreBorrowReader(String preBorrowReader) {
        this.preBorrowReader = preBorrowReader;
    }

    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    public boolean isCanBorrow() {
        return canBorrow;
    }

    public void setCanBorrow(boolean canBorrow) {
        this.canBorrow = canBorrow;
    }

    public static Book convert(FailBook book) {
        Book book1 = new Book();
        book1.setAuthor(book.getAuthor());
        book1.setBarcode(book.getBarcode());
        book1.setBoxNum(book.getBoxNum());
        book1.setAuthor(book.getAuthor());
        book1.setName(book.getName());
        book1.setPreBorrowReader(book.getReader());
        return book1;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null){
            return false;
        }
        if (o instanceof String) {
            return Objects.equals(barcode, o);
        }
        if (getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return Objects.equals(barcode, book.barcode);
    }

    @Override
    public String toString() {
        return "Book{" +
                "Id=" + Id +
                ", name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", barcode='" + barcode + '\'' +
                ", isbn='" + isbn + '\'' +
                ", boxNum=" + boxNum +
                ", preBorrowReader='" + preBorrowReader + '\'' +
                '}';
    }
    public boolean getCanBorrow() {
        return this.canBorrow;
    }
}
